// file: main.go
package main

import "github.com/kataras/iris/v12"

// 调试方案
func main() {
	app := iris.New()

	tmpl := iris.HTML("./web/views", ".html")
	tmpl.Reload(true)

	// Default template funcs are:
	tmpl.AddFunc("greet", func(s string) string {
		return "Greetings " + s + "!"
	})

	// Register the view engine to the views,
	// this will load the templates.
	app.RegisterView(tmpl)
	app.HandleDir("/public", "./web/public")

	// Method:    GET
	// Resource:  http://localhost:8080
	app.Get("/", func(ctx iris.Context) {
		// Bind: {{.message}} with "Hello world!"
		ctx.ViewData("message", "Hello world!")
		// Render template file: ./views/hi.html
		ctx.View("test/hi.html")
	})

	app.Run(iris.Addr(":8081"))
}